<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ManagementCard extends BaseModel
{
    use HasFactory;
    //抽号机管理卡管理
    protected $table = 'management_card';
    // 允许批量操作的字段
    protected $fillable = [
        'card_number',
        'card_name',
        'remark',
        'is_del',
        'created_at',
        'updated_at'
    ];

    public function scopeSearch($query,$params)
    {
        if(!empty($params['card_name'])){
            $query->where('card_name','like','%'.$params['card_name'].'%');
        }
        if(!empty($params['card_number'])){
            $query->where('card_number',$params['card_number']);
        }
        $query->where('is_del',$params['is_del']??2);
        return $query;
    }
}
